package com.jyw.business.obstacles.domain.vo.web;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.jyw.common.annotation.Conversion;
import com.jyw.common.annotation.Excel;
import com.jyw.common.constant.SysDictTypeConstant;
import com.jyw.common.enums.ConversionType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;

/**
 * @author w_q
 * @date 2023/8/1714:03
 * @Description:
 */
@Data
@ApiModel("待处理工单返回VO")
public class WorkOrderPageVO {

    @ApiModelProperty(value = "工单id")
    private String id;

    @ApiModelProperty(value = "故障描述")
    private String faultRemark;

    @ApiModelProperty(value = "工单号")
    private String orderNum;

    @ApiModelProperty(value = "科室名称")
    private String deptName;

    @ApiModelProperty(value = "报修科室ID")
    private Long deptId;

    @ApiModelProperty(value = "故障类型")
    @Conversion(value = ConversionType.DICT,dictType = SysDictTypeConstant.OBS_FAULT_TYPE)
    private String faultType;

    @ApiModelProperty(value = "故障类型名称")
    private String faultTypeToName;

    @ApiModelProperty(value = "报修时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    @ApiModelProperty(value = "报修电话")
    private String phone;

    @ApiModelProperty(value = "报修人")
    private String user;

    @ApiModelProperty(value = "完成时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date completeDate;

    @ApiModelProperty(value = "处理人")
    private String makeUser;

    @ApiModelProperty("是否超时 1是 0否")
    private Integer overTime;

    @ApiModelProperty("工单处理耗时(分钟)")
    private BigDecimal makeTime;

    @ApiModelProperty("标准时间(分钟)")
    private BigDecimal maxTime;

    @ApiModelProperty("预计完成时间")
    private Date completeTime;


    public BigDecimal getMakeTime() {
        if(!ObjectUtils.isEmpty(makeTime)){
            return makeTime.setScale(2, RoundingMode.HALF_DOWN);
        }
        return makeTime;
    }

    public BigDecimal getMaxTime() {
        if(!ObjectUtils.isEmpty(maxTime)){
            return maxTime.setScale(2, RoundingMode.HALF_DOWN);
        }
        return maxTime;
    }
}
